package web.servlet.pet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.PetServiceImpl;
import domain.Pet;

public class PetListServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		//调用 业务逻辑
		PetServiceImpl psi = new PetServiceImpl();
		List<Pet> list = psi.findAllPets();
		
		//跳转页面
		if(list!=null){
			request.setAttribute("pets", list);//把list放入到request对象中
			request.getRequestDispatcher("/admin/pet/list.jsp").forward(request, response);
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
